package com.nineshadow.games.Enum;


import java.util.Map;

/**
 * <p>
 * 前后端交互状态
 * </p>
 *
 * @author ting liu
 * @since 2018/12/3 9:55
 */
public enum ResultStatusEnum {
    FAILURE(0),
    SUCCESS(1);

    private int code;

    ResultStatusEnum(int code) {
        this.code = code;
    }


    public static Map<String, Object> putSuccessMsg(Map<String, Object> map, String msg) {
        map.put("success", SUCCESS.code);
        map.put("msg", msg);
        return map;
    }
    public static Map<String, Object> putSuccessMsg(Map<String, Object> map) {
        map.put("success", SUCCESS.code);
        map.put("msg", "操作成功");
        return map;
    }

    public static Map<String, Object> putFailureMsg(Map<String, Object> map, String msg) {
        map.put("success", FAILURE.code);
        map.put("msg", msg);
        return map;
    }
    public static Map<String, Object> putFailureMsg(Map<String, Object> map) {
        map.put("success", SUCCESS.code);
        map.put("msg", "操作失败");
        return map;
    }
    public static Map<String, Object> putMsgAndCode(Map<String, Object> map, int code, String msg) {
        map.put("success", code);
        map.put("msg", msg);
        return map;
    }

    public int getCode() {
        return code;
    }
}
